SET(LIBRARY_NAME xodr)

SET(TARGET_HEADERS
    xodr.h
)

SET(TARGET_SOURCES
    xodr.cxx
)

INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) # for export_header.h

ADD_LIBRARY(${LIBRARY_NAME} ${TARGET_SOURCES} ${TARGET_HEADERS})

TARGET_LINK_LIBRARIES(${LIBRARY_NAME} pugixml)

TARGET_INCLUDE_DIRECTORIES(xodr PUBLIC
    $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../
    $<INSTALL_INTERFACE:./>  # <prefix>
)

set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)

GENERATE_EXPORT_HEADER(${LIBRARY_NAME})

SET_TARGET_PROPERTIES(${LIBRARY_NAME} PROPERTIES FOLDER ${PROJECT_NAME}/lib)

SET_TARGET_PROPERTIES(${LIBRARY_NAME} PROPERTIES VERSION ${XODR_VERSION} SOVERSION ${XODR_VERSION_MAJOR})

TARGET_COMPILE_DEFINITIONS(${LIBRARY_NAME} PUBLIC ${LIBRARY_NAME}_EXPORTS)

if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
    TARGET_COMPILE_OPTIONS(${LIBRARY_NAME} PUBLIC -fPIC -Wno-subobject-linkage)
else()
    TARGET_COMPILE_OPTIONS(${LIBRARY_NAME} PUBLIC -fPIC)
endif()

install(FILES ${TARGET_INSTALL_HEADERS} ${TARGET_HEADERS} ${CMAKE_CURRENT_BINARY_DIR}/${LIBRARY_NAME}_export.h DESTINATION ${CMAKE_INSTALL_PREFIX}/include)
